import request from '@/utils/request'

// 设备管理API接口
export const equipmentApi = {
  // 分页查询设备列表
  getEquipmentPage(params) {
    return request({
      url: '/equipment/all',
      method: 'post',
      data: params
    })
  },

  // 根据ID查询设备详情
  getEquipmentDetail(equipId) {
    return request({
      url: '/equipment/byid',
      method: 'get',
      params: { equipId }
    })
  },

  // 新增设备
  addEquipment(data) {
    return request({
      url: '/equipment/addequip',
      method: 'post',
      data
    })
  },

  // 编辑设备
  updateEquipment(data) {
    return request({
      url: '/equipment/editequip',
      method: 'post',
      data
    })
  },

  // 删除设备
  deleteEquipment(equipId) {
    return request({
      url: '/equipment/delequip',
      method: 'delete',
      params: { equipId }
    })
  },

  // 获取所有设备名称列表
  getAllEquipmentNames() {
    return request({
      url: '/equipment/equipmentNames',
      method: 'get'
    })
  },

  // 初始化测试数据
  initTestData() {
    return request({
      url: '/equipment/initTestData',
      method: 'post'
    })
  }
}

// 设备运维记录API接口
export const equipmentMaintenanceApi = {
  // 分页查询设备运维记录
  getMaintenancePage(params) {
    return request({
      url: '/equipmentMaintenance/page',
      method: 'post',
      data: params
    })
  },

  // 根据ID查询设备运维记录详情
  getMaintenanceDetail(equipmentMaintenanceId) {
    return request({
      url: `/equipmentMaintenance/${equipmentMaintenanceId}`,
      method: 'get'
    })
  },

  // 新增设备运维记录
  addMaintenance(data) {
    return request({
      url: '/equipmentMaintenance/add',
      method: 'post',
      data
    })
  },

  // 修改设备运维记录
  updateMaintenance(data) {
    return request({
      url: '/equipmentMaintenance/update',
      method: 'put',
      data
    })
  },

  // 删除设备运维记录
  deleteMaintenance(equipmentMaintenanceId) {
    return request({
      url: `/equipmentMaintenance/delete/${equipmentMaintenanceId}`,
      method: 'delete'
    })
  }
}

// 保养记录API接口
export const maintenanceRecordApi = {
  // 分页查询保养记录
  getMaintenanceRecordPage(params) {
    return request({
      url: '/maintenanceRecord/page',
      method: 'post',
      data: params
    })
  },

  // 根据ID查询保养记录详情
  getMaintenanceRecordDetail(maintenanceRecordId) {
    return request({
      url: `/maintenanceRecord/${maintenanceRecordId}`,
      method: 'get'
    })
  },

  // 新增保养记录
  addMaintenanceRecord(data) {
    return request({
      url: '/maintenanceRecord/add',
      method: 'post',
      data
    })
  },

  // 修改保养记录
  updateMaintenanceRecord(data) {
    return request({
      url: '/maintenanceRecord/update',
      method: 'put',
      data
    })
  },

  // 删除保养记录
  deleteMaintenanceRecord(maintenanceRecordId) {
    return request({
      url: `/maintenanceRecord/${maintenanceRecordId}`,
      method: 'delete'
    })
  }
}
